package com.polaris.live.ui.message.widget.single_message

import com.polaris.live.R
import com.polaris.live.adapter.MessageAdapter
import com.polaris.live.databinding.MessageItemNoticeBinding
import com.polaris.live.im.db.entity.MessageEntity
import com.polaris.live.utils.route.RouterUtils

/**
 * 通知消息
 *
 * @author Created by lucas on 2023/10/23 20:19
 * @since 1.0.0
 */
class MessageNoticeItemHolder(
    adapter: MessageAdapter,
    binding: MessageItemNoticeBinding
) : AbstractMessageItemHolder<MessageItemNoticeBinding>(adapter, binding) {

    override fun bind(item: MessageEntity) {
        mBinding.apply {
            if (item.payloadBean?.background == 1) {
                flBg.setBackgroundResource(R.drawable.shape_message_notice_bg)
            } else {
                flBg.setBackgroundResource(0)
            }

            item.payloadBean.also {
                if (it?.highlight != null) {
                    RouterUtils.handleRouterText(tvNotice, item.content, it.highlight, it.router ?: emptyMap())
                } else {
                    tvNotice.text = item.content
                }
            }
        }
    }
}